<%@ page import="com.xszx.entity.TUser" %><%--
  Created by IntelliJ IDEA.
  User: 32312
  Date: 2024/1/9
  Time: 10:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%
    TUser user = (TUser)request.getSession().getAttribute("user");
    String deptName = (String)request.getSession().getAttribute("deptName");
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="/resource/materialize/css/materialize.min.css" media="screen,projection" />
    <!-- Bootstrap Styles-->
    <link href="/resource/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="/resource/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->
    <link href="/resource/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
    <!-- Custom Styles-->
    <link href="/resource/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="/resource/js/Lightweight-Chart/cssCharts.css">
</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand waves-effect waves-dark" href="/jsp/index.jsp"><i class="large material-icons">insert_chart</i> <strong>固定资产管理</strong></a>

            <div id="sideNav" href=""><i class="material-icons dp48">toc</i></div>
        </div>

        <ul class="nav navbar-top-links navbar-right">
            <li><a class="dropdown-button waves-effect waves-dark" href="#!" data-activates="dropdown1"><i class="fa fa-user fa-fw"></i> <b>${user.username}</b> </a></li>
        </ul>
    </nav>
    <!-- Dropdown Structure -->
    <ul id="dropdown1" class="dropdown-content">
        <li><a href="/jsp/form.jsp"><i class="fa fa-user fa-fw"></i> 个人中心</a>
        </li>
        <li><a href="/jsp/personCenter.jsp"><i class="fa fa-bell fa-fw"></i> 个人任务</a>
        </li>
        <li><a href="/jsp/test.jsp" target="_top"><i class="fa fa-sign-out fa-fw"></i> 注销</a>
        </li>
    </ul>
    <ul id="dropdown2" class="dropdown-content w250">
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-comment fa-fw"></i> New Comment
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-twitter fa-fw"></i> 3 New Followers
                    <span class="pull-right text-muted small">12 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-envelope fa-fw"></i> Message Sent
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-tasks fa-fw"></i> New Task
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-upload fa-fw"></i> Server Rebooted
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a class="text-center" href="#">
                <strong>See All Alerts</strong>
                <i class="fa fa-angle-right"></i>
            </a>
        </li>
    </ul>
    <!--/. NAV TOP  -->
    <!--/. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">


                <li>
                    <a class="active-menu waves-effect waves-dark" href="/jsp/index.jsp"><i class="fa fa-dashboard"></i> 统计</a>
                </li>

                <li>
                    <a href="#" class="waves-effect waves-dark"><i class="fa fa-sitemap"></i>固定资产管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="#">资产管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/assetTable.jsp">总资产管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFixTable.jsp">维修资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetForbiddenTable.jsp">禁用资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFreeTable.jsp">空闲资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetScrapTable.jsp">报废资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetUsingTable.jsp">使用中资产</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="/jsp/recordTable.jsp">合同管理</a>
                        </li>
                        <li>
                            <a href="#">系统管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/deptTable.jsp">部门管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/user.jsp">用户管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/roleTable.jsp">角色管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/menuTable.jsp">菜单管理</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="/jsp/empty.jsp" class="waves-effect waves-dark"><i class="fa fa-fw fa-file"></i> 日志</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper" >
        <div class="header">
            <h1 class="page-header">
                禁用资产
            </h1>
            <ol class="breadcrumb">
                <li><a href="#">Home</a></li>
                <li><a href="#">禁用资产</a></li>
                <li class="active">数据</li>
            </ol>

        </div>

<%--        资产列表--%>
        <div id="page-inner">

            <div class="row">
                <div class="col-md-12">
                    <div class="input-field inline" style="width: 200px">
                        资产编号：<input type="text" id="checkid" style="width: 100px">
                    </div>
                    <div class="input-field inline" style="width: 200px">
                        资产名称：<input type="text" id="checkname"style="width: 100px">
                    </div>
                    <div class="input-field inline" style="width: 200px">
                        资产价值：<input type="text" id="min" style="width: 100px">
                    </div>

                    <button type="button" class="btn signin_btn" id="check">
                        查询
                    </button>
                    <!-- Advanced Tables -->
                    <div class="card">
                        <div class="card-content">
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>资产编号</th>
                                        <th>资产名称</th>
                                        <th>入库部门</th>
                                        <th>规格型号</th>
                                        <th>资产状态</th>
                                        <th>现存地址</th>
                                        <th>操    作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="assetList">
                                        <%--ajax拼接表单数据--%>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->

<%--    资产详情--%>
    <div class="modal fade details" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="sign-content">

                    <div class="modal-header">
                        <h2>资产详情</h2>
                    </div><!--/.modal-header -->

                    <div class="modal-body">
                        <div class="signin-form">
                            <div class=" ">
                                <div class=" ">
                                    <form action="">
                                        <div class="form-group">
                                            <label for="signin_aid">资产编号</label>
                                            <input type="text" class="form-control" readonly name="aid" id="signin_aid" placeholder="aid">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aname">资产名称</label>
                                            <input type="text" class="form-control" readonly name="aname" id="signin_aname" placeholder="aname">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aprice">资产价格</label>
                                            <input type="text" class="form-control" readonly name="aprice" id="signin_aprice" placeholder="aprice">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aintodept">入库部门</label>
                                            <input type="text" class="form-control" readonly name="aintodept" id="signin_aintodept" placeholder="aintodept">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_astatus">资产状态</label>
                                            <input type="text" class="form-control" readonly name="astatus" id="signin_astatus" placeholder="astatus">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aserial">规格型号</label>
                                            <input type="text" class="form-control" readonly name="aserial" id="signin_aserial" placeholder="aserial">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_address">现存地址</label>
                                            <input type="text" class="form-control" readonly name="address" id="signin_address" placeholder="address">
                                        </div>
                                        <div class="signin-footer">
                                            <a href="/jsp/assetForbiddenTable.jsp">
                                                <button type="button" class="btn signin_btn" data-toggle="modal" data-target=".signin_modal">
                                                    退出
                                                </button>
                                            </a>
                                        </div>
                                    </form><!--/form -->
                                </div><!--/.col -->
                            </div><!--/.row -->

                        </div><!--/.signin-form -->

                    </div><!--/.modal-body -->

                </div><!--/.sign-content -->
            </div><!--/.modal-content -->
        </div><!--/.modal-dialog -->
    </div><!--/.modal -->


    <%--    修改资产--%>
    <div class="modal fade upda" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="sign-content">

                    <div class="modal-header">
                        <h2>资产详情</h2>
                    </div><!--/.modal-header -->

                    <div class="modal-body">
                        <div class="signin-form">
                            <div class=" ">
                                <div class=" ">
                                    <form action="/updateAsset">
                                        <div class="form-group">
                                            <label for="signin_aid">资产编号</label>
                                            <input type="text" class="form-control" readonly name="aid" id="signin_aid" placeholder="aid">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aname">资产名称</label>
                                            <input type="text" class="form-control" readonly name="aname" id="signin_aname" placeholder="aname">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aprice">资产价格</label>
                                            <input type="text" class="form-control" name="aprice" id="signin_aprice" placeholder="aprice">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_intodept">入库部门</label>
                                            <select class="form-control" name="aintodept" id="signin_intodept" placeholder="选择部门">
                                                <option value="">选择部门</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="status">资产状态</label>
                                            <select class="form-control" name="astatus" id="status" placeholder="选择状态">
                                                <option value="选择状态">选择状态</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aserial">规格型号</label>
                                            <input type="text" class="form-control" name="aserial" id="signin_aserial" placeholder="aserial">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_address">现存地址</label>
                                            <input type="text" class="form-control" name="address" id="signin_address" placeholder="address">
                                        </div>
                                        <div class="signin-footer">
                                            <button type="submit" class="btn signin_btn" data-toggle="modal" data-target=".signin_modal">
                                                保存
                                            </button>
                                        </div>
                                    </form><!--/form -->
                                </div><!--/.col -->
                            </div><!--/.row -->

                        </div><!--/.signin-form -->

                    </div><!--/.modal-body -->

                </div><!--/.sign-content -->
            </div><!--/.modal-content -->
        </div><!--/.modal-dialog -->
    </div><!--/.modal -->

    <%--    删除弹框--%>
    <div class="modal fade del" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="sign-content">

                    <div class="modal-header">
                        <h2>你确定要删除该资产吗</h2>
                    </div><!--/.modal-header -->

                    <div class="modal-body">
                        <div class="signin-form">
                            <div class=" ">
                                <div class=" ">
                                    <form action="/deleteAssetById">
                                        <div class="form-group">
                                            <label for="signin_aid">资产编号</label>
                                            <input type="text" class="form-control" readonly name="aid" id="signin_aid" placeholder="aid">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aname">资产名称</label>
                                            <input type="text" class="form-control" readonly name="aname" id="signin_aname" placeholder="aname">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aprice">资产价格</label>
                                            <input type="text" class="form-control" readonly name="aprice" id="signin_aprice" placeholder="aprice">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aintodept">入库部门</label>
                                            <input type="text" class="form-control" readonly name="aintodept" id="signin_aintodept" placeholder="aintodept">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_astatus">资产状态</label>
                                            <input type="text" class="form-control" readonly readonly name="astatus" id="signin_astatus" placeholder="astatus">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_aserial">规格型号</label>
                                            <input type="text" class="form-control" readonly name="aserial" id="signin_aserial" placeholder="aserial">
                                        </div>
                                        <div class="form-group">
                                            <label for="signin_address">现存地址</label>
                                            <input type="text" class="form-control" readonly name="address" id="signin_address" placeholder="address">
                                        </div>
                                        <div class="signin-footer">
                                            <button type="submit" class="btn signin_btn" data-toggle="modal" data-target=".signin_modal">
                                                保存
                                            </button>
                                        </div>
                                    </form><!--/form -->
                                </div><!--/.col -->
                            </div><!--/.row -->

                        </div><!--/.signin-form -->

                    </div><!--/.modal-body -->

                </div><!--/.sign-content -->
            </div><!--/.modal-content -->
        </div><!--/.modal-dialog -->
    </div><!--/.modal -->


    <!-- /. WRAPPER  -->
    <!-- JS Scripts-->


    <!-- jQuery Js -->
    <script src="/resource/js/jquery-1.10.2.js"></script>

    <!-- Bootstrap Js -->
    <script src="/resource/js/bootstrap.min.js"></script>

    <script src="/resource/materialize/js/materialize.min.js"></script>

    <!-- Metis Menu Js -->
    <script src="/resource/js/jquery.metisMenu.js"></script>
    <!-- Morris Chart Js -->
    <script src="/resource/js/morris/raphael-2.1.0.min.js"></script>
    <script src="/resource/js/morris/morris.js"></script>


    <script src="/resource/js/easypiechart.js"></script>
    <script src="/resource/js/easypiechart-data.js"></script>

    <script src="/resource/js/Lightweight-Chart/jquery.chart.js"></script>
    <!-- DATA TABLE SCRIPTS -->
    <script src="/resource/js/dataTables/jquery.dataTables.js"></script>
    <script src="/resource/js/dataTables/dataTables.bootstrap.js"></script>
    <script>
        $(document).ready(function () {
            $('#dataTables-example').dataTable();
        });


        function insertCon() {
            $.ajax({
                url: "/insertContract",
                data:{
                    cname:$(".cname").val(),
                    ctype:$("#ctype").val(),
                    armorName:$(".armorName").val(),
                    armorPhone: $("#armorPhone").val(),
                    armorDept: $("#deptName").val(),
                    secondName:$(".secondsName").val(),
                    secondPhone:$("#secondsPhone").val(),
                    secondDept:$("#secondsDept").val(),
                    aname:$(".assetsName").val(),
                    aserial:$(".assetsAserial").val(),
                    acode:$(".assetsAcode").val(),
                    aprice:$(".assetsPrice").val()
                },
                dataType: "json",
                type: "post",
                success:function (data){
                    if(data=="0"){
                        alert("调度失败")
                    } else {
                        location.href="/jsp/assetTable.jsp";
                    }
                }
            })
        }
        $("#check").click(function () {
            $.ajax({
                    url: "/selectAssetsByCheck",
                    dataType: "json",
                    type: "post",
                    data:{
                        acode:$("#checkid").val(),
                        aname:$("#checkname").val(),
                        aprice:$("#min").val(),
                        astatus:'禁用'
                    },
                    success:function (data){
                        $('#assetList').empty();
                        console.log(data)
                        for(let i=0;i<data.length;i++){
                            $("#assetList").
                            append("<tr>" +
                                "<td>"+data[i].aid+"</td>" +
                                "<td>"+data[i].aname+"</td>" +
                                "<td>"+data[i].aintodept+"</td>" +
                                "<td>"+data[i].aserial+"</td>" +
                                "<td>"+data[i].astatus+"</td>" +
                                "<td>"+data[i].aaddress+"</td>" +
                                "<td>" +
                                "<button class=btn signin_btn data-toggle=modal data-target=.del onclick='deleteData("+data[i].aid+")'>" +
                                "删除" +
                                "</button>" +
                                "<button class=btn signin_btn data-toggle=modal data-target=.details onclick='particulars("+data[i].aid+")'>" +
                                "查看详情" +
                                "</button>" +
                                "</td>")
                        }
                    }
                }
            )

        })

        $(function () {
            $.ajax({
                url: "/selectAssetForbidden",
                dataType: "json",
                type: "post",
                success:function (data){
                    console.log(data)
                    for(let i=0;i<data.length;i++){
                        $("#assetList").
                        append("<tr>" +
                            "<td>"+data[i].aid+"</td>" +
                            "<td>"+data[i].aname+"</td>" +
                            "<td>"+data[i].aintodept+"</td>" +
                            "<td>"+data[i].aserial+"</td>" +
                            "<td>"+data[i].astatus+"</td>" +
                            "<td>"+data[i].aaddress+"</td>" +
                            "<td>" +
                            "<button class=btn signin_btn data-toggle=modal data-target=.upda onclick='updateData("+data[i].aid+")'>" +
                            "修改" +
                            "</button>" +
                            "<button class=btn signin_btn data-toggle=modal data-target=.del onclick='deleteData("+data[i].aid+")'>" +
                            "删除" +
                            "</button>" +
                            "<button class=btn signin_btn data-toggle=modal data-target=.details onclick='particulars("+data[i].aid+")'>" +
                            "查看详情" +
                            "</button>" +
                            "</td>")
                    }
                }
            })
        })

        function particulars(aid){
            $.ajax({
                url: "/selectAssetByAid",
                data:{
                  aid:aid
                },
                type: "get",
                dataType: "json",
                success:function (data){
                    console.log(data)
                    $("[name='aid']").val(data.aid);
                    $("[name=aname]").val(data.aname);
                    $("[name=aprice]").val(data.aprice);
                    $("[name=aintodept]").val(data.aintodept);
                    $("[name=astatus]").val(data.astatus);
                    $("[name=aserial]").val(data.aserial);
                    $("[name=address]").val(data.aaddress);

                }
            })
        }

        function updateData(aid){
            $.ajax({
                url: "/selectAssetByAid",
                data:{
                    aid:aid
                },
                type: "get",
                dataType: "json",
                success:function (data){
                    console.log(data)
                    $("[name='aid']").val(data.aid);
                    $("[name=aname]").val(data.aname);
                    $("[name=aprice]").val(data.aprice);
                    $("[name=aintodept]").val(data.aintodept);
                    $("[name=astatus]").val(data.astatus);
                    $("[name=aserial]").val(data.aserial);
                    $("[name=address]").val(data.aaddress);

                }
            })
        }


        function deleteData(aid){
            $.ajax({
                url: "/selectAssetByAid",
                data:{
                    aid:aid
                },
                type: "get",
                dataType: "json",
                success:function (data){
                    console.log(data)
                    $("[name='aid']").val(data.aid);
                    $("[name=aname]").val(data.aname);
                    $("[name=aprice]").val(data.aprice);
                    $("[name=aintodept]").val(data.aintodept);
                    $("[name=astatus]").val(data.astatus);
                    $("[name=aserial]").val(data.aserial);
                    $("[name=address]").val(data.aaddress);
                }
            })
        }

        function scheduling(aid){
            $.ajax({
                url: "/selectAssetByAid",
                data:{
                    aid:aid
                },
                type: "get",
                dataType: "json",
                success:function (data){
                    console.log(data)
                    $(".assetsName").val(data.aname);
                    $(".assetsPrice").val(data.aprice);
                    // $("").val(data.aintodept);
                    $(".assetsAserial").val(data.aserial);
                    $(".assetsAcode").val(data.acode);
                }
            })
        }

        $.ajax({
            url: "/selectDeptList",
            async: false,
            type: "get",
            dataType: "json",
            success:function (data){
                console.log(data)
                for (let i=0;i<data.length;i++){
                    $("#signin_intodept").
                    append("<option value="+data[i].dname+">"+data[i].dname+"</option>")
                }
            }
        })

        $.ajax({
            url: "/selectStatusList",
            async: false,
            type: "get",
            dataType: "json",
            success:function (data){
                console.log(data)
                for (let i=0;i<data.length;i++){
                    $("#status").
                    append("<option value="+data[i]+">"+data[i]+"</option>")
                }
            }
        })


    </script>
    <!-- Custom Js -->
    <script src="/resource/js/custom-scripts.js"></script>
</div>
</body>

</html>

